package com.ljx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ljx.pojo.EduTeacher;
import com.ljx.mapper.EduTeacherMapper;
import com.ljx.service.EduTeacherService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 讲师 服务实现类
 * </p>
 *
 * @author 李加喜
 * @since 2020-09-22
 */
@Service
public class EduTeacherServiceImpl extends ServiceImpl<EduTeacherMapper, EduTeacher> implements EduTeacherService {
    //分页查询讲师的信息
    @Override
    public Map<String, Object> getTeacherFrontList(Page<EduTeacher> page, Object o) {
        QueryWrapper<EduTeacher> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("sort");
        baseMapper.selectPage(page,wrapper);
        HashMap<String, Object> map = new HashMap<>();
        map.put("total",page.getTotal());
        map.put("records",page.getRecords());

        map.put("size",page.getSize());
        map.put("current",page.getCurrent());
        map.put("pages",page.getPages());
        boolean next = page.hasNext();//判断当前是否具有下一页
        boolean hasPrevious = page.hasPrevious();//判断是都具有下一页
        map.put("next",next);
        map.put("previous",hasPrevious);
        System.out.println("+++"+page.getRecords());
        return map;
    }
    //根据讲师的
}
